package tec.stan.ling.topo;

import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IFolder;

import tec.stan.ling.core.top.ex.AbstractTopoService;
import tec.stan.ling.core.top.model.Link;
import tec.stan.ling.core.top.model.Subnet;
import tec.stan.ling.core.util.WorkspaceUtil;
import tec.stan.ling.topo.demo.DemoUtil;

public class TopoService extends AbstractTopoService {

	private static final String MODEL_FILE = "model.xml";
	private Subnet root = null;

	public void loadService() {
		try {
			IFolder topo = WorkspaceUtil.getTopoFolder(null);
			IFile file = topo.getFile(MODEL_FILE);
			if (file.exists()) {
				root = DemoUtil.loadNE(file);
			} else {
				root = DemoUtil.createDemo();
//				DemoUtil.saveNE(file, root);
			}
		} catch (Exception e) {
			e.printStackTrace();
		}
	}

	@Override
	public Link[] getLinks() {
		return null;
	}

	public Subnet getRoot() {
		return root;
	}

}
